Conversation
Summary: - add fixed template-cut generation logic, tests, and design docs for TIA-52 - add an AI panel presets view that generates drafts from current project assets - route template generation through actions and an undoable timeline command Rationale: - provide a fast first-cut workflow without introducing AI-only orchestration - keep generation deterministic and reusable by isolating composition logic - preserve editor expectations by supporting undo and existing shortcut typing Tests: - bun test - bunx @biomejs/biome lint apps/web/src/lib/auto-edit/generate-template-cut.ts apps/web/src/lib/auto-edit/templates.ts apps/web/src/lib/auto-edit/generate-template-cut.test.ts apps/web/src/lib/commands/timeline/template/generate-template-cut.ts apps/web/src/lib/commands/timeline/template/index.ts apps/web/src/lib/actions/definitions.ts apps/web/src/lib/actions/types.ts apps/web/src/hooks/actions/use-editor-actions.ts apps/web/src/hooks/use-keyboard-shortcuts-help.ts apps/web/src/components/editor/panels/assets/views/ai-template-cuts.tsx apps/web/src/components/editor/panels/assets/views/ai.tsx apps/web/src/components/editor/panels/timeline/timeline-element.tsx apps/web/src/components/editor/panels/timeline/timeline-toolbar.tsx apps/web/src/stores/keybindings-store.ts --max-diagnostics=1000 - UPSTASH_REDIS_REST_URL=https://example.com UPSTASH_REDIS_REST_TOKEN=test bun run build:web Co-authored-by: Codex <codex@openai.com>
|
Warning Rate limit exceeded
⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (15)
📝 WalkthroughWalkthroughThis pull request implements a one-click template cuts feature for the editor's AI panel. Users can select from three predefined templates (clean-cut, story-pulse, memory-album), which automatically generate timeline layouts from imported visual and audio assets. The implementation includes template definitions, timeline track generation logic, an undoable command system, UI components, action integration, and translations across 12 languages. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant AIPanel as AI Panel (Templates View)
participant Editor as Editor Actions
participant Generator as Template Generator
participant Timeline as Timeline Manager
participant Command as Command System
participant Undo as Undo/Redo Stack
User->>AIPanel: Select template & click Generate
alt Timeline has existing content
AIPanel->>User: Show confirmation dialog
User->>AIPanel: Confirm replacement
end
AIPanel->>Editor: Invoke "generate-template-cut" action
Editor->>Generator: generateTemplateCut(templateId, assets)
Generator-->>Editor: Returns GeneratedTemplateCut with tracks
Editor->>Timeline: timeline.generateTemplateCut(tracks)
Timeline->>Command: new GenerateTemplateCutCommand(tracks)
Command->>Command: Save current tracks state
Command->>Timeline: Apply new tracks to timeline
Timeline-->>Command: Execution complete
Command->>Undo: Register command for undo/redo
Editor->>Editor: Stop playback, clear selection
Editor->>AIPanel: Show success toast
AIPanel-->>User: Display updated timeline
User->>Undo: Press Ctrl+Z (Undo)
Undo->>Command: Invoke undo()
Command->>Timeline: Restore saved tracks state
Timeline-->>Undo: Restoration complete
Undo-->>User: Timeline reverted
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
There was a problem hiding this comment.
Actionable comments posted: 14
🧹 Nitpick comments (1)
apps/web/src/lib/auto-edit/generate-template-cut.ts (1)
167-168: Consider a more appropriate fallback duration for audio assets.Using
template.imageDurationas fallback for audio duration is semantically inconsistent—imageDurationis designed for still images, not audio clips. If an audio file lacks duration metadata, this could result in unexpectedly short audio elements.Consider adding a dedicated
defaultAudioDurationto the template definition or using a longer fallback value.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web/src/lib/auto-edit/generate-template-cut.ts` around lines 167 - 168, The current audio element duration fallback in the audioAssets.map callback uses template.imageDuration (see AudioElement construction and the duration constant), which is semantically wrong for audio; update the template shape to include a dedicated defaultAudioDuration (or at least use a longer numeric fallback like DEFAULT_AUDIO_DURATION) and change the fallback expression from template.imageDuration to template.defaultAudioDuration (or the new constant) so audio files without metadata receive an appropriate audio-specific duration.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@apps/web/next-env.d.ts`:
- Line 3: Remove the manual import line import "./.next/types/routes.d.ts"; from
the auto-generated next-env.d.ts file (do not edit next-env.d.ts directly), and
instead add the generated types path (for example ".next/types/**/*.ts" or
include ".next/types" in typeRoots) to your tsconfig.json "include" or
"typeRoots" so the routes types are picked up without modifying next-env.d.ts.
In `@apps/web/public/locales/de/translation.json`:
- Line 34: The German locale file contains English placeholder strings for
several keys (e.g., "k1f07c90") which causes mixed-language UI; for each
referenced key ("k1f07c90" and additionally the keys at lines noted: those
corresponding to positions 95, 210, 226, 244, 281, 309, 354, 366) either provide
proper German translations for the values or remove the keys so the app falls
back to English intentionally; update the translation values in
apps/web/public/locales/de/translation.json ensuring each key's value is valid
German text (or delete the key entries) and keep the key names unchanged.
In `@apps/web/public/locales/es/translation.json`:
- Line 34: The Spanish locale contains English placeholder strings (e.g., key
"k1f07c90") that will show mixed-language UI; update each listed key ("k1f07c90"
plus the other affected keys referenced in the comment) by replacing the English
value with the correct Spanish translation, or remove the keys if you intend to
rely on English fallback; ensure you only commit fully translated values for
keys like k1f07c90 so Spanish users receive a consistent localization.
In `@apps/web/public/locales/fr/translation.json`:
- Line 34: Several keys in the French locale (e.g., "k1f07c90" and the other
listed keys for the new template-cut strings) are still English; update each
key's value to a proper French translation or remove the key if you intend to
rely on English fallback, ensuring no English placeholders remain in apps/web
public locales/fr/translation.json; locate the keys (like "k1f07c90" and the
other eight keys mentioned) and either replace the English text with French
translations or delete the entries, then run the i18n validation/test to confirm
no missing translations.
In `@apps/web/public/locales/id/translation.json`:
- Line 34: The Indonesian locale file contains English placeholder values (e.g.,
key "k1f07c90") that must be replaced with proper Indonesian translations or
removed; update apps/web/public/locales/id/translation.json by translating the
listed keys (k1f07c90 and the other keys at the mentioned positions) into
Indonesian (or delete the keys if you intend to rely on English fallback), then
run the i18n validator/linter to ensure no English strings remain in the id
locale and commit the cleaned translations.
In `@apps/web/public/locales/it/translation.json`:
- Line 34: Replace the English values with proper Italian translations for the
listed keys in apps/web/public/locales/it/translation.json: set k1f07c90 ->
"Impossibile generare la bozza del modello", k371fd2a0 -> "Generazione bozza del
modello in corso...", k6c4c8ae0 -> "Importa prima le risorse visive", k713d4cc5
-> "Bozza del modello generata", k79cf0712 -> "Risorse audio", k88fdb5ec ->
"Modelli con un clic...", k96ebf9b -> "Vai a Media", kaab263db -> "Sostituire la
timeline corrente?", kafb2473b -> "Risorse visive"; update the JSON values for
these keys accordingly and ensure punctuation and capitalization match existing
translation style.
In `@apps/web/public/locales/ja/translation.json`:
- Line 34: Several keys in the Japanese locale contain English placeholders
(e.g., "k1f07c90") and should not be checked in as English; locate the keys
including "k1f07c90" and the other new template-related keys added in this
change and either replace their English string values with proper Japanese
translations or remove the keys if you intend to rely on English fallback, then
run the i18n extraction/validation step to ensure there are no missing
translations.
In `@apps/web/public/locales/ko/translation.json`:
- Line 34: The Korean locale contains English placeholder strings (e.g., the key
"k1f07c90" with value "Failed to generate template draft"); replace these
English values with proper Korean translations for each affected key (or remove
the keys if you intend to rely on English fallback), making sure to update the
values in the ko translation JSON and keep the keys intact (or consistently
omitted) for the other reported entries as well so the Korean locale contains no
English UI text.
In `@apps/web/public/locales/pt/translation.json`:
- Line 34: The Portuguese locale contains English placeholder strings (e.g., key
"k1f07c90" with value "Failed to generate template draft" and eight other
template-cut keys added to the pt translation file) which must be translated or
removed; update each offending key in the Portuguese translation JSON to a
proper Portuguese string (or delete the key if you intend to rely on English
fallback), ensuring the values for "k1f07c90" and the other newly added template
keys are replaced with correct Portuguese translations and that the JSON remains
valid.
In `@apps/web/public/locales/ru/translation.json`:
- Line 34: The listed translation entries in
apps/web/public/locales/ru/translation.json (keys k1f07c90, k371fd2a0,
k6c4c8ae0, k713d4cc5, k79cf0712, k88fdb5ec, k96ebf9b, kaab263db, kafb2473b)
still contain English strings; replace each English value with the appropriate
Russian translation (use the Italian locale entries as a reference for meaning
and tone), ensuring proper grammar and context for UI template-generation
messages and keeping JSON string formatting intact.
In `@apps/web/public/locales/vi/translation.json`:
- Line 34: Several i18n entries in the Vietnamese translations are still in
English; update the JSON values for the keys "k1f07c90", "k94", "k207", "k223",
"k241", "k277", "k305", "k350", and "k362" (use the exact keys shown in the
diff/file) to proper Vietnamese strings, ensuring you replace the English
phrases with accurate Vietnamese translations, preserve the existing JSON key
names and punctuation, and validate the file remains valid UTF-8 JSON after
edits (no trailing commas or broken quotes).
In `@apps/web/src/lib/commands/timeline/template/generate-template-cut.ts`:
- Around line 12-16: In execute(), savedState currently holds a direct reference
from EditorCore.getInstance().timeline.getTracks(), which allows later mutations
to leak into undo; replace that assignment so savedState =
structuredClone(editor.timeline.getTracks()) to capture an immutable deep copy
(keep rest of logic, e.g., editor.timeline.updateTracks(this.tracks) unchanged)
and ensure the savedState type supports the clone so undo() restores the exact
snapshot.
In `@apps/web/src/stores/keybindings-store.ts`:
- Around line 15-16: The code unsafely casts getDefaultShortcuts() to
KeybindingConfig allowing actions that require args (e.g.,
generate-template-cut) to be assigned to shortcuts; update the initialization of
defaultKeybindings so you first filter the result of getDefaultShortcuts() to
only include keybindable actions (i.e., actions that do not require runtime
args) before casting/assigning. Implement or use a predicate like
isKeybindable(action) and apply it when building the mapping returned from
getDefaultShortcuts(), referencing defaultKeybindings, getDefaultShortcuts,
KeybindingConfig, ShortcutKey and any action identifiers (e.g.,
generate-template-cut) so only valid actions become keyboard shortcuts. Ensure
the filtered object matches KeybindingConfig shape before assignment.
In `@docs/plans/2026-03-17-one-click-video.md`:
- Line 13: Change the task headings that use `###` directly after the H1 to one
level lower (`##`) to satisfy markdown-lint MD001; specifically update the
heading "Task 1: 建立一键成片生成器的测试骨架" and the other task headings that currently
start with `###` (the subsequent task headings referenced in the review) to use
`##` so there is no H1→H3 jump, keeping the rest of heading hierarchy intact.
---
Nitpick comments:
In `@apps/web/src/lib/auto-edit/generate-template-cut.ts`:
- Around line 167-168: The current audio element duration fallback in the
audioAssets.map callback uses template.imageDuration (see AudioElement
construction and the duration constant), which is semantically wrong for audio;
update the template shape to include a dedicated defaultAudioDuration (or at
least use a longer numeric fallback like DEFAULT_AUDIO_DURATION) and change the
fallback expression from template.imageDuration to template.defaultAudioDuration
(or the new constant) so audio files without metadata receive an appropriate
audio-specific duration.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 4a2ed51d-d6e4-449f-8e4c-4d7f2f4719ba
📒 Files selected for processing (31)
apps/web/next-env.d.tsapps/web/public/locales/de/translation.jsonapps/web/public/locales/en/translation.jsonapps/web/public/locales/es/translation.jsonapps/web/public/locales/fr/translation.jsonapps/web/public/locales/id/translation.jsonapps/web/public/locales/it/translation.jsonapps/web/public/locales/ja/translation.jsonapps/web/public/locales/ko/translation.jsonapps/web/public/locales/pt/translation.jsonapps/web/public/locales/ru/translation.jsonapps/web/public/locales/vi/translation.jsonapps/web/public/locales/zh/translation.jsonapps/web/src/components/editor/panels/assets/views/ai-template-cuts.tsxapps/web/src/components/editor/panels/assets/views/ai.tsxapps/web/src/components/editor/panels/timeline/timeline-element.tsxapps/web/src/components/editor/panels/timeline/timeline-toolbar.tsxapps/web/src/core/managers/timeline-manager.tsapps/web/src/hooks/actions/use-editor-actions.tsapps/web/src/hooks/use-keyboard-shortcuts-help.tsapps/web/src/lib/actions/definitions.tsapps/web/src/lib/actions/types.tsapps/web/src/lib/auto-edit/generate-template-cut.test.tsapps/web/src/lib/auto-edit/generate-template-cut.tsapps/web/src/lib/auto-edit/templates.tsapps/web/src/lib/commands/timeline/index.tsapps/web/src/lib/commands/timeline/template/generate-template-cut.tsapps/web/src/lib/commands/timeline/template/index.tsapps/web/src/stores/keybindings-store.tsdocs/plans/2026-03-17-one-click-video-design.mddocs/plans/2026-03-17-one-click-video.md
Summary: - add audio-specific fallback duration and deep-copy undo state for template cuts - replace English placeholder locale strings with localized copy in reviewed languages - filter default keybindings to keybindable actions and fix plan heading levels Rationale: - resolve CodeRabbit review items that affected localization and state safety - keep generated next-env changes out of the PR diff while relying on tsconfig includes for route types - preserve reviewability by limiting this commit to feedback-driven fixes Tests: - bun test - bunx @biomejs/biome lint apps/web/next-env.d.ts apps/web/public/locales/de/translation.json apps/web/public/locales/es/translation.json apps/web/public/locales/fr/translation.json apps/web/public/locales/id/translation.json apps/web/public/locales/it/translation.json apps/web/public/locales/ja/translation.json apps/web/public/locales/ko/translation.json apps/web/public/locales/pt/translation.json apps/web/public/locales/ru/translation.json apps/web/public/locales/vi/translation.json apps/web/src/lib/commands/timeline/template/generate-template-cut.ts apps/web/src/lib/auto-edit/templates.ts apps/web/src/lib/auto-edit/generate-template-cut.ts apps/web/src/stores/keybindings-store.ts docs/plans/2026-03-17-one-click-video.md --max-diagnostics=1000 - UPSTASH_REDIS_REST_URL=https://example.com UPSTASH_REDIS_REST_TOKEN=test bun run build:web Co-authored-by: Codex <codex@openai.com>
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
已处理本轮 CodeRabbit 的可执行反馈:
已重新验证:
|
Issue:
Summary:
Validation:
bun testbunx @biomejs/biome lint apps/web/src/lib/auto-edit/generate-template-cut.ts apps/web/src/lib/auto-edit/templates.ts apps/web/src/lib/auto-edit/generate-template-cut.test.ts apps/web/src/lib/commands/timeline/template/generate-template-cut.ts apps/web/src/lib/commands/timeline/template/index.ts apps/web/src/lib/actions/definitions.ts apps/web/src/lib/actions/types.ts apps/web/src/hooks/actions/use-editor-actions.ts apps/web/src/hooks/use-keyboard-shortcuts-help.ts apps/web/src/components/editor/panels/assets/views/ai-template-cuts.tsx apps/web/src/components/editor/panels/assets/views/ai.tsx apps/web/src/components/editor/panels/timeline/timeline-element.tsx apps/web/src/components/editor/panels/timeline/timeline-toolbar.tsx apps/web/src/stores/keybindings-store.ts --max-diagnostics=1000UPSTASH_REDIS_REST_URL=https://example.com UPSTASH_REDIS_REST_TOKEN=test bun run build:webNotes:
bun run lint:web在当前环境下会因为biome不在 PATH 而失败,且仓库本身存在与本次改动无关的全局 lint 诊断,因此这里对变更文件做了精确 lint。bun run build:web默认会因为/api/upload/image在构建期校验 Upstash 环境变量而失败,因此验证时补了占位环境变量。Summary by CodeRabbit
New Features
Localization
Tests